<template>
  <div ref="box" style="width:400px;height:400px;" />
</template>

<script>
import axios from 'axios'
import rederData from '@/views/dashboard/map/radar/radarData'
import * as Echarts from 'echarts'
export default {
  name: 'MasterRedar',
  data() {
    return {
      list: [],
      list1: []
    }
  },
  mounted() {
    this.echarts = Echarts.init(this.$refs.box)
    this.echarts.setOption(rederData)
    this.time = setInterval(() => {
      this.getpeiData()
    }, 3000)
  },
  created() {
    this.getpeiData()
  },
  destroyed() {
    clearInterval(this.time)
    this.time = null
  },

  methods: {
    async getpeiData() {
      const { data } = await axios.get('/mock/echarts/radar')
      // console.log('雷达图', data)
      this.list = data.data.cate
      // console.log(this.list)
      const arr = []
      this.list.map(item => {
        arr.push(item.count)
      })

      this.list1 = data.data.goods
      const arr1 = []
      this.list1.map(item => {
        arr1.push(item.count)
      })

      rederData.series[0].data[0].value = arr
      rederData.series[0].data[1].value = arr1
      this.echarts.setOption(rederData)
    }

  }
}
</script>

<style lang="scss" scoped>

</style>
